package com.tenc.vo;

/**
 * @author Alan
 * @since 2021-05-14
 * 返回结果
 */
public enum ApiEnum {
    SUCCESS(200,"操作成功"),

    FAIL(500, "操作失败");

    private final Integer code ;
    private final String message;

    ApiEnum(final Integer code, final String message){
        this.code =code;
        this.message=message;
    }

    public static ApiEnum getApiCode(int code) {
        ApiEnum[] ecs = ApiEnum.values();
        for (ApiEnum ec : ecs) {
            if (ec.getCode() == code) {
                return ec;
            }
        }
        return SUCCESS;
    }

    public Integer getCode(){
        return code;
    }

    public String getMessage(){
        return message;
    }
}
